<div class="lore-section">
    <div class="section-light">
        <div class="box-section">
            <div class="section-col">
                <div class="main-div">
                    <div class="section-title">
                        <h1 class="h1-section">登录或创建帐户</h1>
                    </div>
                    <div class="box-content">
                        <div class="inside-box">
                            <div class="left-inside">
                                <div class="login-left">
                                    <p class="t-login">
                                        <span class="t-left">密码登陆</span>
                                        <span class="t-right">短信验证码登陆</span>
                                    </p>
                                    <div class="login-block">
                                        <form action="javascript:void(0)" id="dior">
                                            <ul class="ul-login">
                                                <li class="li-name">
                                                    <p class="p-name">用户名</p>
                                                    <div class="login-in">
                                                        <input type="text" class="name" id="username"
                                                            placeholder="手机号 / 邮箱">
                                                    </div>
                                                </li>
                                                <li class="li-name">
                                                    <p class="p-name">密码</p>
                                                    <div class="login-in">
                                                        <input type="text" id="password" class="name" placeholder="密码">
                                                        <p class="alerts">用户名和密码不符</p>
                                                    </div>
                                                </li>
                                                <li class="li-check">
                                                    <div class="check-block">
                                                        <p href="" class="sign">
                                                            <span class="sign-ch"></span>
                                                        </p>
                                                        <p class="agree">我已阅读并接受<span
                                                                class="sp-agree">个人信息收集声明</span>以及<span
                                                                class="sp-agree">网站使用和销售条款</span></p>
                                                    </div>
                                                </li>
                                                <li class="li-login">
                                                    <a class="forget">忘记密码?</a>
                                                    <a class="btn" id="login" style="cursor: pointer;">登录</a>
                                                </li>
                                            </ul>
                                        </form>
                                    </div>
                                </div>
                            </div>
                            <div class="right-inside">
                                <div class="box-right">
                                    <p class="right-top">注册迪奥账户</p>
                                    <p class="right-under">注册Dior账号以便追踪您的订单，<br>管理收货地址，获取更多个性化信息</p>
                                </div>
                                <div class="create">
                                    <a class="a-create" href="./register.html"><span class="span-create">创建账户</span></a>
                                </div>
                            </div>



                        </div>
                    </div>
                    <div class="box-text">
                        *请妥善保管您的注册账户信息，勿将账号及密码随意泄露给他人。<br>
                        请注意，您的账户注册手机号为迪奥识别及验证您账户身份的唯一依据。
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<script>
    //  同意协议按钮
    $(function () {
        $(".sign-ch").click(function () {
            if (!$(this).hasClass("box")) {
                $(this).addClass("box")
            } else {
                $(this).removeClass("box");
            }
        })
    })
</script>


<script>

    //禁止为空


</script>


<script>

 
    // 登录

    $(function () {
        $("#login").click(function () {
            var dormitory = $(".name").val();	//获取input框内的值
            if (dormitory == null || dormitory == "") {
                alert("请填写信息");	//如果值为空，提示用户填写
                return;
            }

            $.ajax({
                url: "http://localhost/server/login.php",
                data: {
                    username: $("#username").val(),
                    password: $("#password").val()
                },
            })
                .then(function (res) {
                    var data = JSON.parse(res);
                    if (data.type === "success") {
                        $(".alerts").css({
                            display: "none"
                        })
                        alert("登录成功,点击确定1秒后返回主页")
                        setTimeout(function () {
                            window.location.href = "index.html"
                        }, 1000)
                    } else {
                        $(".alerts").css({
                            display: "block"
                        })
                    }
                })



        })
    })
</script>